package org.example.java8.lambda;

import java.util.function.Consumer;

public class MethodReference {
    public static void main(String[] args) {
        Consumer<String> consumer = s -> System.out.println(s);
        useConsumer(consumer, "hello Alex");

        useConsumer(s -> System.out.println(s), "Hello Alex");

        useConsumer(System.out::println, "Hello Alex");
    }

    //泛型参数列表置于返回值前
    private static <T> void useConsumer(Consumer<T> consumer, T t) {
        consumer.accept(t);
    }
}
